<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>租金提醒沟通记录表 管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<form id="rskCommRec_form">
    <div class="fieldset1 tabel_col noBorder clearFix">
        <div class="fieldBox col_33">
            <div class="label">客户名称</div>
            <div class="field">
                <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="${rskCommRecVO.cstNm}" readonly validate="{required:true}">
            </div>
            <input name="cstId" id="cstId" type="text" style="display: none;" value="${rskCommRecVO.cstId}" >
        </div>
        <div class="fieldBox col_33">
            <div class="label">还款方式</div>
            <div class="field">
                <input name="payTypCd" id="payTypCd" data-value="${rskCommRecVO.payTypCd}" placeholder="请选择" ltype="combobox">
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">任务人</div>
            <div class="field">
                <input name="collectUsrNm" id="collectUsrNm" type="text" class="ui-textbox" value="${rskCommRecVO.collectUsrNm}" validate="{required:true}">
                <span class="requiredSymbol">*</span>
                <input name="collectUsrId" id="collectUsrId" type="text" style="display: none;" value="${rskCommRecVO.collectUsrId}" >
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">联系人</div>
            <div class="field">
                <input name="lkMan" id="lkMan" type="text" class="ui-textbox" value="${rskCommRecVO.lkMan}"
                       validate="{required:true,maxlength:60}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">联系电话</div>
            <div class="field">
                <input name="lkPhone" id="lkPhone" type="text" class="ui-textbox" value="${rskCommRecVO.lkPhone}"
                       validate="{required:true,maxlength:20}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">提醒时间</div>
            <div class="field">
                <input name="collectTm" id="collectTm" type="text" class="ui-datepicker" value="${rskCommRecVO.collectTms}" validate="{required:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">提醒方式</div>
            <div class="field">
                <input name="collectWayCd" id="collectWayCd" data-value="${rskCommRecVO.collectWayCd}" validate="{required:true}" placeholder="请选择" ltype="combobox">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_66_auto">
            <div class="label">沟通记录</div>
            <div class="field">
                <textarea name="collectRem" id="collectRem" type="text" class="ui-textbox" cols="125" rows="2"
                          value="${rskCommRecVO.collectRem}" style="width: 98%;"
                          validate="{required:false,maxlength:200}">${rskCommRecVO.collectRem}</textarea>
                <input name="buTypCd" id="buTypCd" type="text" style="display:none;" value="2">
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label" style="width: 155px">客户反馈受新型肺炎影响</div>
            <div class="field">
                <select name="cstFeedbackCd" id="cstFeedbackCd">
                    <c:forEach items="${cstFeedbackCdList}" var="cfb">
                        <option value="${cfb.key}">${cfb.value}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label" style="width: 155px">公司审批受新型肺炎影响</div>
            <div class="field">
                <select name="compFeedbackCd" id="compFeedbackCd">
                    <c:forEach items="${compFeedbackCdList}" var="cfb">
                        <option value="${cfb.key}">${cfb.value}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="fieldBox col_33">
            <div class="label">贷前风险标记</div>
            <div class="field">
                <input name="preLoanRskInfo" id="preLoanRskInfo" type="text" class="ui-textbox" value="${rskCommRecVO.preLoanRskInfo}"  readonly="readonly">
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label" style="width: 155px">贷后风险核查</div>
            <div class="field">
                <select name="postLoanRskCd" id="postLoanRskCd">
                    <c:forEach items="${postLoanRskInfoList}" var="cfb">
                        <option value="${cfb.key}">${cfb.value}</option>
                    </c:forEach>
                </select>
                <span class="requiredSymbol">*</span>
            </div>
        </div>
    </div>

    <div class="btnsBox">
        <span id="saveRskCommRec_Btn" class="sq-button sq-button-round">保存</span>
    </div>


    <div class="sqPanel">
        <div class="sqPanel_head inL">
            <span>沟通记录</span>
        </div>
        <div class="sqPanel_body">
            <div id="ligergrid_collect" class="sq-grid"></div>
        </div>
    </div>
</form>
<script>
    var grid=null,rskCommRecId=null;
    $(function () {
        grid = $("#ligergrid_collect").ligerGrid({
            url: '<%=path%>/risk/rskCommRec/initList.do?cstId=${cstId}&buTypCd=2',
            method: 'get',
            columns: [
                {display: '客户名称', name: 'cstNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '提醒时间', name: 'collectTm', width: 80, align: 'left', enabledSort: false,render:renderDate},
                {display: '提醒方式', name: 'collectWayCdNm', width: 80, align: 'center', enabledSort: false},
                {display: '任务人', name: 'collectUsrNm', width: 80, align: 'left', enabledSort: false},
                {display: '联系人', name: 'lkMan', width: 70, align: 'left', enabledSort: false},
                {display: '联系电话', name: 'lkPhone', width: 90, align: 'center', enabledSort: false},
                {display: '沟通记录', name: 'collectRem', minWidth: 100, align: 'left', enabledSort: false,
                    render:function(rowdata,index,value){
                        var h='<span class="gridTip" style="cursor: pointer;" title="'+ rowdata.collectRem +'">'+rowdata.collectRem+'</span>';
                        return h;
                    }
                },
                {display: '贷前风险标记', name: 'preLoanRskInfo', width: 90, align: 'center', enabledSort: false},
                {display: '贷后风险核查', name: 'postLoanRskCdNm', width: 90, align: 'center', enabledSort: false},
                {display:'操作',name:'',width:100,align:'center',
                    render:function(rowdata,rowindex,value){
                        return '<a class="sq-button-hasicon" alt="删除" href="javascript:delRow('+rowdata.id+');"><i class="sqBtnIco_7"></i>删除</a>';
                    }
                }
            ],
            onDblClickRow:function(rowdata, rowid, rowobj){
                rskCommRecId=rowdata.id;
                $("#lkMan").val(rowdata.lkMan);
                $("#lkPhone").val(rowdata.lkPhone);
                $("#collectRem").val(rowdata.collectRem);
                liger.get("collectWayCd").setValue(rowdata.collectWayCd);
                liger.get("ovdReasonCd").setValue(rowdata.ovdReasonCd);
                liger.get("collectRstCd").setValue(rowdata.collectRstCd);
                $("#collectTm").val(DateUtils.formatDate(new Date(rowdata.collectTm),DateUtils.YYYY_MM_DD));
            },
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: true,
            enabledEdit: false,
        });
        grid.setHeight(100);

        $("#pageloading").hide();

        rskCommRecId = "${rskCommRecVO.id}";//主键ID

        //催收方式
        $("#collectWayCd").ligerComboBox({
            valueField: 'key',
            textField: 'value',
        });
        //还款方式
        $("#payTypCd").ligerComboBox({
            valueField: 'key',
            textField: 'value',
        });

        $("#rskCommRec_form").ligerForm({
            validate: true
        });
        liger.get("collectWayCd").setData(${collectWayCdList});
        liger.get("payTypCd").setData(${payTypCdList});
        liger.get("payTypCd").setDisabled();

        /*保存*/
        $("#saveRskCommRec_Btn").click(function (event) {
            var form = liger.get("rskCommRec_form");
            if (!form.valid()) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            var data = form.getData();
            $.ligerDialog.hide();
            var _url;
            if (rskCommRecId == '') {//新增
                _url = '<%=path%>/risk/rskCommRec/add.do';
            } else {//修改
                _url = '<%=path%>/risk/rskCommRec/modify.do?id=' + rskCommRecId;
            }
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: _url,
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        grid.reload();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    });

    //删除
    function delRow(_id){
        var _ids = [];
        _ids.push(_id);

        if(rskCommRecId==_id){
            rskCommRecId='';
        }
        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {ids: JSON.stringify(_ids)},
            url: '<%=path%>/risk/rskCommRec/removeByIds.do',
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    grid.reload();
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }
</script>
</body>
</html>
